﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace WgpgGUI
{
    [ValueConversion(typeof(Boolean), typeof(Visibility))]
    public sealed class BooleanToVisibilityConverter : IValueConverter
    {
        public Boolean IsReversed { get; set; }
        public Boolean UseHidden { get; set; }

        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            Boolean val = System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
            if (IsReversed)
                val = !val;

            if (val)
                return Visibility.Visible;

            return this.UseHidden ? Visibility.Hidden : Visibility.Collapsed;
        }

        public object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
